﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace YK.ListItemTransfer
{
    public partial class FormResult : Form
    {
        const string SuccessedHeaderText = "Process completed successfully.";
        const string CancelledHeaderText = "Process cancelled.";

        public string Message
        {
            get
            {
                return labelMessage.Text;
            }
            set
            {
                labelMessage.Text = value;
            }
        }

        public bool IsCancelled { get; set; }

        public string LogFilePath { get; set; }

        public FormResult()
        {
            InitializeComponent();
        }

        private void buttonClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void FormResult_Load(object sender, EventArgs e)
        {
            SetHeader();
        }

        private void SetHeader()
        {
            if (IsCancelled)
                labelHeader.Text = CancelledHeaderText;
            else
                labelHeader.Text = SuccessedHeaderText;
        }

        private void OpenLogFile()
        {
            System.Diagnostics.Process.Start(LogFilePath);
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                OpenLogFile();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
